package com.kobeliu.entity;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

/**
 * @Author: Kobe_Liu
 * @Date: 2021/12/9 16:36
 */
public class Demo_77_No2094 {

    public static void main(String[] args) {



        int[] nums = new int[]{2,1,3,0};
        String s = "123dSSsa3";
//        System.out.println(s.replaceAll("[^a-zA-Z ]", ""));
        s=s.replaceAll("[^a-zA-Z]","").toLowerCase(Locale.ROOT);
//        System.out.println(Arrays.toString(findEvenNumbers(nums)));
    }

    public String shortestCompletingWord(String licensePlate, String[] words) {
        Arrays.sort(words,(a,b)->a.length()-b.length());
        //为26个字母见一张表，统计licensePlate里出现的字母，及其个数
        int[] nums = new int[26];
        licensePlate=licensePlate.replaceAll("[^a-zA-Z]","").toLowerCase(Locale.ROOT);
        int sLen = licensePlate.length();
        int len = words.length;
        String temp = "";
        for(int i=0;i<sLen;i++){
            //统计里面各个字母出现了几次
            nums[licensePlate.charAt(i)-'a']++;
        }
        for(int i=0;i<len;i++){
            if(words[i].length()<sLen) break;
            int[] _nums = new int[26];
            temp = words[i];
            for(int j=0;j<temp.length();j++){
                //统计里面各个字母出现了几次
                _nums[temp.charAt(j)-'a']++;
            }
            for(int j=0;j<26;j++){
                if(nums[i]>_nums[i]) break;
            }
            return words[i];
        }
        return temp;

    }


    public static int[] findEvenNumbers(int[] digits) {

        int num = 0;
        Set<Integer> set = new HashSet<>();
        for(int i=0;i<digits.length;i++){
            for(int j=0;j<digits.length;j++){
                for(int k=0;k<digits.length;k++){
                    if(digits[i]!=0 && i!=j && i!=k && j!=k){
                        num = digits[i]*100 + digits[j]*10 +digits[k];
                        if(num%2==0){
                            set.add(num);
                        }
                    }
                }
            }
        }
        int[] nums = new int[set.size()];
        int i=0;

        for(Integer t:set){
            nums[i++] = t;
        }
        Arrays.sort(nums);
        return nums;

    }
}
